package com.emep.changzhi.analyse.service.datamonitor.day;

import com.emep.changzhi.analyse.entity.datamonitor.day.DataDayAirquality;
import com.emep.changzhi.analyse.repository.datamonitor.day.DataDayAirqualityRepository;
import com.emep.changzhi.analyse.utils.MapUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author yangj
 * @version V1.0
 * @Description: 空气质量_日数据表业务层
 * @date 2018/2/27  15:13
 */
@Slf4j
@Service
public class DataDayAirqualityService {

    @Resource
    private DataDayAirqualityRepository dataDayAirqualityRepository;

    /**
     *
     * 新增
     *
     * @param payload
     * @return
     * @throws Exception
     */
    public DataDayAirquality save(Map<String, Object> payload) {
        DataDayAirquality dataDayAirquality = null;
        try {
            DataDayAirquality dataDayAirquality1 = (DataDayAirquality) MapUtils.convertMap(DataDayAirquality.class,payload);
            dataDayAirquality = dataDayAirqualityRepository.save(dataDayAirquality1);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return dataDayAirquality;
    }

    /**
     * @author xy
     * @Description: 首页
     * @date 2018/3/8 10:11
     * @version V1.0
     */
    public List<DataDayAirquality> findDataDayAirqualityByHome(Integer pageSize){
        List<DataDayAirquality> airQualitys = null;
        try {
            airQualitys = dataDayAirqualityRepository.airQualityHome(pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return airQualitys;

    }
    /**
     * @author xy
     * @Description: 翻页查询
     * @date 2018/3/8 10:18
     * @version V1.0
     */

    public List<DataDayAirquality> findDataDayAirqualityByFlip(String id,Integer pageSize) {
        List<DataDayAirquality> airQualitys = null;
        try {
            airQualitys = dataDayAirqualityRepository.airQualityFlip(id,pageSize);
        }catch (Exception e){
            log.error(e.getClass().getName()+":"+ e.getMessage());
            log.error(e.getLocalizedMessage());
        }
        return airQualitys;
    }


}
